home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sources / libxpm / libxpm34.gz / libxpm34 / xpm-3.4 / lib / XpmCrIFrBuf.c < prev    next >
C/C++ Source or Header  |  1994-03-14  |  2KB  |  76 lines

  1. /* Copyright 1989-94 GROUPE BULL -- See license conditions in file COPYRIGHT */
  2. /*****************************************************************************\
  3. * XpmCrIFrBuf.c:                                                              *
  4. *                                                                             *
  5. *  XPM library                                                                *
  6. *  Parse an Xpm buffer (file in memory) and create the image and possibly its *
  7. *  mask                                                                       *
  8. *  Developed by Arnaud Le Hors                                                *
  9. \*****************************************************************************/
  10.  
  11. #include "xpmP.h"
  12.  
  13. int
  14. XpmCreateImageFromBuffer(display, buffer, image_return,
  15.              shapeimage_return, attributes)
  16.     Display *display;
  17.     char *buffer;
  18.     XImage **image_return;
  19.     XImage **shapeimage_return;
  20.     XpmAttributes *attributes;
  21. {
  22.     XpmImage image;
  23.     XpmInfo info;
  24.     int ErrorStatus;
  25.  
  26.     /* create an XpmImage from the buffer */
  27.     if (attributes) {
  28.     xpmInitAttributes(attributes);
  29.     xpmSetInfoMask(&info, attributes);
  30.     ErrorStatus = XpmCreateXpmImageFromBuffer(buffer, &image, &info);
  31.     } else
  32.     ErrorStatus = XpmCreateXpmImageFromBuffer(buffer, &image, NULL);
  33.  
  34.     if (ErrorStatus != XpmSuccess)
  35.         return (ErrorStatus);
  36.  
  37.     /* create the related ximages */
  38.     ErrorStatus = XpmCreateImageFromXpmImage(display, &image,
  39.                          image_return, shapeimage_return,
  40.                          attributes);
  41.     if (attributes) {
  42.     if (ErrorStatus >= 0)    /* no fatal error */
  43.         xpmSetAttributes(attributes, &image, &info);
  44.     XpmFreeXpmInfo(&info);
  45.     }
  46.  
  47.     /* free the XpmImage */
  48.     XpmFreeXpmImage(&image);
  49.  
  50.     return (ErrorStatus);
  51. }
  52.  
  53. int
  54. XpmCreateXpmImageFromBuffer(buffer, image, info)
  55.     char *buffer;
  56.     XpmImage *image;
  57.     XpmInfo *info;
  58. {
  59.     xpmData mdata;
  60.     int ErrorStatus;
  61.  
  62.     /* init returned values */
  63.     xpmInitXpmImage(image);
  64.     xpmInitXpmInfo(info);
  65.  
  66.     /* open buffer to read */
  67.     xpmOpenBuffer(buffer, &mdata);
  68.  
  69.     /* create the XpmImage from the XpmData */
  70.     ErrorStatus = xpmParseData(&mdata, image, info);
  71.  
  72.     xpmDataClose(&mdata);
  73.  
  74.     return (ErrorStatus);
  75. }
  76.